package cn.sytton.taffecloud.serivce.auth.service.impl;

import cn.sytton.taffecloud.common.base.properties.TokenProperties;
import cn.sytton.taffecloud.common.base.security.LoginUser;
import cn.sytton.taffecloud.common.base.util.JwtUtil;
import cn.sytton.taffecloud.common.servlet.util.ServletUtil;
import cn.sytton.taffecloud.serivce.auth.service.IProfileService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * Profile服务层
 *
 * @author skyrock
 */
@Service
public class ProfileService implements IProfileService {

    @Resource
    private JwtUtil jwtUtil;
    @Resource
    private TokenProperties tokenProperties;

    @Override
    public LoginUser profile() {
        String token = Objects.requireNonNull(ServletUtil.getRequest()).getHeader(tokenProperties.getHeader());
        return jwtUtil.getLoginUser(token);
    }
}
